package com.lavida.common.utils;

import java.lang.annotation.Retention;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Date;

import org.apache.poi.ss.usermodel.DateUtil;


public class ReviewUtil {
	public static final double base = 5000.00;// 纳税基准
	static double rateAmount = 0;// 每月税额
	static double beforeAmount = 0;// 税前金额
	static double totlerate = 0;// 累计税额
	static double[] rate;// 税率
	static double p = 0;// 专项扣除
	static double q = 0;// 速算扣除
	static double n = 0;// 五险一金扣除

	static int month = 1;// 月份
	static double[][] rates = { { 0, 0, 0 }, { 12, 5, 0 },
			{ 120, 10, 0 }, { 240, 15, 0 }};
	public static double[] getRate(int months) {
		double[] rate = {0,0,0};
		for (int i = 1; i < rates.length; i++) {
			if (months < rates[0][0]) {  //0
				rate = rates[0];		//0
				System.out.println("小于"+Arrays.toString(rate));
				break;
			}else if(months==rates[i][0]) {
				rate = rates[i];	
				System.out.println("等于"+Arrays.toString(rate));
				break;
			}
			else if (months>rates[i-1][0] && months < rates[i][0]) {
				rate = rates[i-1];
				System.out.println("大于"+Arrays.toString(rate));
				break;
			}else if(months>rates[rates.length-1][0]) {
				rate = rates[rate.length];
				break;
			}
		}
		return rate;
	}
	//计算本年年假
		public static Double getReview(int months,Date date) {
				rateAmount = 0;
				totlerate = 0;
				System.out.println("-----------年假计算-------------");
				rate = getRate(months);							//获取税收标准
				System.out.println(Arrays.toString(rate));
				rateAmount = rate[1];
				/*rateAmount = new BigDecimal(rateAmount).setScale(0,RoundingMode.FLOOR).doubleValue();*/
				System.out.println(rate[1]);
				return rateAmount;
		}
		//计算明年年假
		public static Double getReviewMs(int months,Date daten,Date dates) {
			rateAmount = 0;
			totlerate = 0;
			System.out.println("-----------年假计算-------------");
			rate = getRate(months);							//获取税收标准
			System.out.println(Arrays.toString(rate));
			Integer days = DateUtils.daysreview(daten);
			System.out.println("适用新年假规制日历天数" + days);
			rateAmount = (((days * rate[1])+((365-days) * rate[1]))/ 365);
			System.out.println(rate[1]);
			return rateAmount;
	}
		public static void main(String[] args) {
			String date = "2019-06-04";
			Double review = getReview(12,DateUtils.parseDate(date));
			System.out.println(review);
		}
}
